<template lang="pug">
.container
  .card
    .card-header
      .card-inner 登录
    .card-body
      svg.login-icon(width='80px', height='80px', viewbox='0 0 80 80', version='1.1', xmlns='http://www.w3.org/2000/svg', xmlns:xlink='http://www.w3.org/1999/xlink')
        defs
          rect#path-1(x='0', y='0', width='80', height='80')
        g#Page-1(stroke='none', stroke-width='1', fill='none', fill-rule='evenodd')
          g#Group-2
            mask#mask-2(fill='white')
              use(xlink:href='#path-1')
            g#Rectangle
            g(id='student-(1)', mask='url(#mask-2)', fill-rule='nonzero')
              path#Shape(d='M40,80 C62.03125,80 80,62.03125 80,40 C80,17.96875 62.03125,0 40,0 C17.96875,0 0,17.96875 0,40 C0,62.03125 17.96875,80 40,80 Z', fill='#FFCA4F')
              polygon#Shape(fill='#F0B97D', points='36.2678125 30.5710938 43.7310938 30.5710938 44.3354688 36.86125 45.4092188 37.7229688 47.6740625 39.1645313 39.9990625 57.2929688 32.3246875 39.1645313 34.589375 37.7229688 35.6635938 36.8617188 36.2673438 30.5710938')
              path#Shape(d='M33.9117188,38.154375 L22.9701563,41.6465625 C22.9701563,41.6465625 21.9054688,42.200625 21.3439063,43.80875 C18.0845313,47.3009375 7.64515625,58.713125 7.64515625,61.6103125 C7.64515625,65.0439063 16.5557813,73.3134375 16.5557813,73.3134375 L20.7851563,73.3134375 L20.7851563,76.2770312 L59.2140625,76.2770312 L59.2140625,73.3135937 L63.44375,73.3135937 C63.44375,73.3135937 72.3542188,65.0439062 72.3542188,61.6104687 C72.3542188,58.7123438 61.913125,47.2992188 58.655,43.8076563 C58.0925,42.2004688 57.0290625,41.6464063 57.0290625,41.6464063 L46.1621875,38.2020313 L45.2403125,40.90625 L39.9996875,40.6520313 L34.8351563,40.9028125 L33.9117188,38.154375 L33.9117188,38.154375 Z M20.7851562,58.160625 L22.1414062,63.57 L21.9015625,69.2846875 L20.7853125,68.0071875 L16.8910937,62.4446875 L20.7853125,58.160625 L20.7851562,58.160625 Z M59.2140625,68.0075 L58.0984375,69.2159375 L57.858125,62.5775 L59.2140625,58.16 L63.1089062,62.4446875 L59.2140625,68.0075 Z', fill='#15BDB1')
              polygon#Shape(fill='#F1F1F1', points='33.805625 38.1884375 32.33375 38.6579688 39.999375 57.2932813 47.7332812 38.7001563 46.1620312 38.2023438 42.3135937 40.5804688 37.6995312 40.5804688 33.8057812 38.1885938')
              path#Shape(d='M33.9117187,38.154375 L31.5514062,38.9078125 L31.0979687,44.8960937 C31.0979687,44.8960937 31.2229687,45.3882812 31.5975,45.3440625 L33.7275,46.1446875 C33.7275,46.1446875 33.866875,46.284375 33.7421875,46.4603125 L31.919375,47.7095313 L38.2175,59.579375 C38.8071875,59.6134375 39.4014062,59.630625 39.9992187,59.630625 C40.5976562,59.630625 41.1914062,59.6134375 41.7810937,59.579375 L48.0790625,47.7096875 L46.25625,46.4607812 C46.1317187,46.2846875 46.2709375,46.1451562 46.2709375,46.1451562 L48.400625,45.344375 C48.775625,45.3885938 48.900625,44.8964062 48.900625,44.8964062 L48.4484375,38.9276563 L46.1614062,38.2023438 L39.9989062,56.2746875 L33.9117187,38.1546875 L33.9117187,38.154375 Z', fill='#20D0C2')
              path#Shape(d='M48.6914062,17.7796875 C48.6914062,18.3640625 48.9048437,18.9367188 48.8889063,19.4975 C50.8889063,19.12625 49.9232813,25.0667188 48.7915625,25.8834375 C48.7017188,25.9484375 48.480625,25.80375 48.2939063,25.6845312 C47.9014063,27.8698438 44.5517188,33.7079687 42.4217188,36.1653125 C41.8301563,36.8478125 38.2132813,36.83625 37.6275,36.1914062 C35.4459375,33.7898438 32.1004688,27.8823438 31.7059375,25.6846875 C31.51875,25.8040625 31.2976563,25.94875 31.2079687,25.8839063 C30.0764063,25.0670313 29.110625,19.1265625 31.110625,19.4979688 C31.095,18.9370313 31.3078125,18.3645313 31.3078125,17.7801563 C31.41875,13.1676563 35.598125,10.8645313 39.9996875,10.845 C44.400625,10.8645313 48.580625,13.1675 48.6910938,17.7803125 L48.6914062,17.7796875 Z', fill='#FED198')
              path#Shape(d='M46.0115625,11.8665625 C46.6420313,11.793125 48.9204687,12.4910937 49.19375,14.9015625 C49.4675,17.3121875 49.3364062,19.5328125 49.3364062,19.5328125 C49.3364062,19.5328125 48.0020312,19.8703125 47.83375,21.238125 C47.6659375,22.6064062 47.785625,22.6064062 47.785625,22.6064062 L47.3023437,22.498125 L46.9579687,20.1523438 C44.9610937,18.90125 46.973125,17.0476562 44.9757812,16.61375 C39.5817187,20.4582812 34.8226562,19.8004688 32.67625,17.991875 C32.67625,17.991875 33.1773437,19.8834375 32.7909375,20.5575 C32.405,21.2325 32.6354688,22.295 32.6354688,22.295 L32.1339062,22.2707812 C32.1339062,22.2707812 32.2245312,19.4851562 31.1107812,19.4973437 C26.8795312,12.5107812 40.2759375,3.83171875 46.011875,11.8667187 L46.0115625,11.8665625 Z', fill='#666666')
              g#Group(transform='translate(33.750000, 35.937500)', fill='#FFFFFF')
                path#Shape(d='M1.86171875,0.025625 C2.0184375,0.0365625 0.03515625,2.256875 0.03515625,2.256875 L1.72328125,7.9946875 L6.24953125,4.6425 C3.7596875,3.43 2.27390625,1.8596875 1.8615625,0.025625 L1.86171875,0.025625 Z M10.6379688,0.025625 C10.4817188,0.0365625 12.4642188,2.256875 12.4642188,2.256875 L10.7759375,7.9946875 L6.24984375,4.6425 C8.7396875,3.43 10.225625,1.8596875 10.638125,0.025625 L10.6379688,0.025625 Z')
              path#Shape(d='M20.395,69.9765625 C22.946875,69.9765625 25.0153125,71.260625 25.0153125,72.844375 C25.0153125,74.4279688 22.946875,75.7121875 20.395,75.7121875 C17.843125,75.7121875 15.7746875,74.4278125 15.7746875,72.844375 C15.7746875,71.260625 17.843125,69.9765625 20.395,69.9765625 Z M20.395,70.7340625 C18.4090625,70.7340625 16.7996875,71.6796875 16.7996875,72.844375 C16.7996875,74.0096875 18.4090625,74.9553125 20.395,74.9553125 C22.3809375,74.9553125 23.990625,74.0096875 23.990625,72.844375 C23.990625,71.6796875 22.3809375,70.7340625 20.395,70.7340625 L20.395,70.7340625 Z', fill='#ECF0F1')
              path#Shape(d='M20.395,74.955 C22.3753125,74.955 23.990625,74.0070313 23.990625,72.8446875 C23.990625,71.6821875 22.3753125,70.7340625 20.395,70.7340625 C18.4146875,70.7340625 16.7996875,71.6821875 16.7996875,72.8446875 C16.7996875,74.006875 18.4146875,74.955 20.395,74.955 Z', fill='#377BB9')
              path#Shape(d='M18.931875,74.05 L18.931875,76.3609375 C18.931875,76.6476562 18.6978125,76.8821875 18.410625,76.8821875 L17.491875,76.8821875 C17.205,76.8821875 16.9704687,76.6478125 16.9704687,76.3610938 L16.9704687,72.7848438 C16.9704687,72.7301563 16.9792187,72.6775 16.995,72.6278125 L16.995,71.8403125 C16.995,71.17125 17.5425,70.6239063 18.211875,70.6239063 L25.7353125,70.6239063 C26.4045312,70.6239063 26.9515625,71.1710938 26.9515625,71.8404687 L26.9515625,72.6267187 C26.9678125,72.6767188 26.97625,72.7298438 26.97625,72.785 L26.97625,76.3615625 C26.97625,76.6479687 26.741875,76.8825 26.455,76.8825 L25.53625,76.8825 C25.249375,76.8825 25.015,76.648125 25.015,76.3614063 L25.015,74.0504687 L24.2946875,74.0504687 L24.2946875,76.3614063 C24.2946875,76.6479687 24.060625,76.8825 23.7734375,76.8825 L22.8546875,76.8825 C22.5676562,76.8825 22.3332812,76.648125 22.3332812,76.3614063 L22.3332812,74.0504687 L21.6132812,74.0504687 L21.6132812,76.3614063 C21.6132812,76.6479687 21.3789062,76.8825 21.0920312,76.8825 L20.1729687,76.8825 C19.8857812,76.8825 19.6517187,76.648125 19.6517187,76.3614063 L19.6517187,74.0504687 L18.9317187,74.0501562 L18.931875,74.05 Z', fill='#FBB429')
              path#Shape(d='M59.6054688,69.9765625 C57.0539063,69.9765625 54.9854688,71.260625 54.9854688,72.844375 C54.9854688,74.4279688 57.0539063,75.7121875 59.6054688,75.7121875 C62.1573437,75.7121875 64.2257812,74.4278125 64.2257812,72.844375 C64.2257812,71.260625 62.1570312,69.9765625 59.6054688,69.9765625 Z M59.6054688,70.7340625 C61.5914062,70.7340625 63.2010937,71.6796875 63.2010937,72.844375 C63.2010937,74.0096875 61.5917187,74.9553125 59.6054688,74.9553125 C57.6195313,74.9553125 56.0101563,74.0096875 56.0101563,72.844375 C56.0101563,71.6796875 57.6195313,70.7340625 59.6054688,70.7340625 L59.6054688,70.7340625 Z', fill='#ECF0F1')
              path#Shape(d='M59.6057812,74.955 C61.5859375,74.955 63.2014062,74.0070313 63.2014062,72.8446875 C63.2014062,71.6821875 61.5857813,70.7340625 59.605625,70.7340625 C57.6253125,70.7340625 56.0103125,71.6821875 56.0103125,72.8446875 C56.0103125,74.006875 57.6253125,74.955 59.605625,74.955 L59.6057812,74.955 Z', fill='#333333')
              path#Shape(d='M61.06875,74.05 L61.06875,76.3609375 C61.06875,76.6476562 61.3028125,76.8821875 61.59,76.8821875 L62.50875,76.8821875 C62.7959375,76.8821875 63.03,76.6478125 63.03,76.3610938 L63.03,72.7848438 C63.03,72.7301563 63.0214062,72.6775 63.005625,72.6278125 L63.005625,71.8403125 C63.005625,71.17125 62.4584375,70.6239063 61.7890625,70.6239063 L54.265625,70.6239063 C53.59625,70.6239063 53.0489063,71.1710938 53.0489063,71.8404687 L53.0489063,72.6267187 C53.0325,72.6767188 53.0242188,72.7298438 53.0242188,72.785 L53.0242188,76.3615625 C53.0242188,76.6479687 53.2582813,76.8825 53.5453125,76.8825 L54.464375,76.8825 C54.7509375,76.8825 54.9854687,76.648125 54.9854687,76.3614063 L54.9854687,74.0504687 L55.7057813,74.0504687 L55.7057813,76.3614063 C55.7057813,76.6479687 55.9401563,76.8825 56.226875,76.8825 L57.145625,76.8825 C57.433125,76.8825 57.6670312,76.648125 57.6670312,76.3614063 L57.6670312,74.0504687 L58.3873437,74.0504687 L58.3873437,76.3614063 C58.3873437,76.6479687 58.6214062,76.8825 58.9084375,76.8825 L59.8271875,76.8825 C60.1140625,76.8825 60.348125,76.648125 60.348125,76.3614063 L60.348125,74.0504687 L61.0684375,74.0501562 L61.06875,74.05 Z', fill='#FBB429')
              path#Shape(d='M19.3903125,47.6875 L60.6096875,47.6875 C61.9260937,47.6875 63.0029687,48.764375 63.0029687,50.0803125 L63.0029687,72.861875 C63.0029687,74.1779688 61.9259375,75.2553125 60.6095312,75.2553125 L19.3903125,75.2553125 C18.0739063,75.2553125 16.996875,74.1779688 16.996875,72.861875 L16.996875,50.0803125 C16.996875,48.764375 18.0739063,47.6873438 19.3903125,47.6873438 L19.3903125,47.6875 Z', fill='#FFFFFF')
              path#Shape(d='M17.905,76.4292187 L62.095,76.4292187 C62.5945313,76.4292187 63.003125,76.8379687 63.003125,77.338125 L63.003125,79.0896875 C63.003125,79.59 62.594375,79.9982812 62.095,79.9982812 L17.905,79.9982812 C17.4053125,79.9982812 16.9965625,79.5898438 16.9965625,79.0895312 L16.9965625,77.3379688 C16.9965625,76.8379688 17.4053125,76.4290625 17.905,76.4290625 L17.905,76.4292187 Z', fill='#C8CACC')
              g#Group(transform='translate(23.750000, 57.968750)', fill='#ECF0F1')
                path#Shape(d='M0.00421875,16.7384375 L3.91015625,16.7384375 L3.91015625,19.4015625 L0.00421875,19.4015625 L0.00421875,16.7384375 Z M28.5904687,16.7384375 L32.49625,16.7384375 L32.49625,19.4015625 L28.590625,19.4015625 L28.590625,16.7384375 L28.5904687,16.7384375 Z M11.9165625,0.053125 L20.583125,0.053125 C20.6995312,0.053125 20.7940625,0.14796875 20.7940625,0.264375 L20.7940625,2.22625 C20.7940625,2.3425 20.6995312,2.4371875 20.583125,2.4371875 L11.9165625,2.4371875 C11.8003125,2.4371875 11.705625,2.3425 11.705625,2.22625 L11.705625,0.264375 C11.7059375,0.14796875 11.8003125,0.0534375 11.9165625,0.0534375 L11.9165625,0.053125 Z')
      .form
        input.form-control(v-model='user.email')
        input.form-control(type='password', v-model='user.password')
        button.btn.login-btn(@click='login') 登录

  v-snackbar(:open.sync='openSnackbar')
</template>

<script>
import vSnackbar from '~components/snackbar'

export default {
  data () {
    return {
      user: {},
      openSnackbar: false
    }
  },

  methods: {
    async login () {
      let { email, password } = this.user

      if (!email || !password) {
        this.openSnackbar = true

        return ''
      }

      let res = await this.$store.dispatch('login', this.user)

      if (res.success) this.$router.push('/admin')
    }
  },

  components: {
    vSnackbar
  }
}
</script>


<style scoped lang='sass' src='~static/sass/admin.sass'></style>





